package io.admin.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.admin.common.service.impl.CrudServiceImpl;
import io.admin.modules.sys.dao.AddressDao;
import io.admin.modules.sys.dto.AddressDTO;
import io.admin.modules.sys.entity.AddressEntity;
import io.admin.modules.sys.service.AddressService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 地区表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2024-07-06
 */
@Service
public class AddressServiceImpl extends CrudServiceImpl<AddressDao, AddressEntity, AddressDTO> implements AddressService {

    @Override
    public QueryWrapper<AddressEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        String level = (String)params.get("level");
        Long parentId = (Long)params.get("parentId");
        QueryWrapper<AddressEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        wrapper.eq(StrUtil.isNotBlank(level), "level", level);
        wrapper.eq(null!=parentId,"parent_id", parentId);
        return wrapper;
    }


}